package com.tping.thread;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CyclicBarrier;

public class CallableThread implements Callable<List<String>> {

    String sign;
    CyclicBarrier cyclic;

    CallableThread(String sign, CyclicBarrier cyclic){
        this.sign = sign;
        this.cyclic = cyclic;
    }

    @Override
    public List<String> call() throws Exception {

        List<String> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            list.add(sign + "_" + i);
        }

        System.out.println(Thread.currentThread().getName() + "操作完毕...进入wait");
        cyclic.wait();
        return list;
    }
}
